package cn.com.dbappsecurity.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import cn.com.dbappsecurity.entity.User;

public interface UserMapper {

	/**
	 * 插入一个用户
	 * @param user
	 * @return
	 * @throws Exception
	 */
	public int insert(User user)throws Exception;
	
	/**
	 * 删除用户
	 * @param ids
	 * @return
	 * @throws Exception
	 */
	public int delete(@Param("ids")Integer[] ids)throws Exception;
	
	/**
	 * 用户登录
	 * @param name
	 * @param password
	 * @return
	 * @throws Exception
	 */
	public User login(@Param("name")String name,@Param("password")String password)throws Exception;
	
	/**
	 * 用户查询
	 * @param name
	 * @param createTimeFrom
	 * @param createTimeTo
	 * @param loginTimeFrom
	 * @param loginTimeTo
	 * @param limit
	 * @param num
	 * @param sort
	 * @param order
	 * @return
	 * @throws Exception
	 */
	public List<User> search(@Param("name")String name,
			@Param("createTimeFrom")String createTimeFrom,
			@Param("createTimeTo")String createTimeTo,
			@Param("loginTimeFrom")String loginTimeFrom,
			@Param("loginTimeTo")String loginTimeTo,
			@Param("limit")int limit,
			@Param("num")int num,
			@Param("sort")String sort,
			@Param("order")String order)throws Exception;
	
	/**
	 * 用户查询总条数
	 * @param name
	 * @param createTimeFrom
	 * @param createTimeTo
	 * @param loginTimeFrom
	 * @param loginTimeTo
	 * @return
	 * @throws Exception
	 */
	public int searchCount(@Param("name")String name,
			@Param("createTimeFrom")String createTimeFrom,
			@Param("createTimeTo")String createTimeTo,
			@Param("loginTimeFrom")String loginTimeFrom,
			@Param("loginTimeTo")String loginTimeTo)throws Exception;
	
	/**
	 * 查询指定的用户是否已经存在
	 * @param name
	 * @return
	 * @throws Exception
	 */
	public int userExist(@Param("name")String name)throws Exception;
	
	/**
	 * 修改用户
	 * @param user
	 * @return
	 * @throws Exception
	 */
	public int update(User user)throws Exception;
	
}
